
/**************************** F_INTERVAL.HPP ******************************
 * This is the Header File for the class F_Interval and it1s a part of
 * Fast Interval library.
 * Fast Interval is implemented for use with C-XSC data types
 *
 * Developed by: Dimas Gabriel <dimas@dimasgabriel.net>
 *
 * License: GPL v3.0
 *************************************************************************/

#include "real.hpp"
#include <fenv.h>

using namespace cxsc;

//Start operations whit Fast Interval
//This sets the Rounding Mode to Down and stores the current Round Mode
inline int startInterval();

//Stop operations with Fast Interval
//this sets the Round Mode to the old Round stores in startInterval
inline void stopInterval(int mode);

class f_interval
{
    private:
        real inf;
        real nsup;

    public:
        //------------Constructors------------//
        
        //Constructor of class f_interval
        f_interval() {}
        //Constructor of class f_interval
        inline f_interval(const real&, const real&);
        
        //Implementation of standard assigning operator
        inline f_interval& operator= (const real& a);
        
        //-------Standard IO Functions------//
        
        //Standard Output Method
        //Return an IO C++ Stream
        friend std::ostream& operator << (std::ostream& s, const f_interval& a);
        
        //Standard Output Method
        //Return an C++ String :)
        friend std::string & operator << (std::string & s, const f_interval & a);
        
        //-------END of Standard IO Functions------//
        
        //--------Mathematical Functions---------//
        
        //Standard algebric negative sign operation
        friend inline f_interval operator -(const f_interval &);
        
        //Standard algebric positive sign operation
        friend inline f_interval operator +(const f_interval &);
        
        //Standard algebric addition operation
        friend f_interval operator +(const f_interval &, const f_interval &);
        
        //Standard algebric subtraction operation
        friend f_interval operator -(const f_interval &, const f_interval &);
        
        //Standard algebric multiplication operation
        friend f_interval operator *(const f_interval &, const f_interval &);
        
        /*Standard algebric division operation
        friend f_interval operator /(const f_interval &, const f_interval &);*/
        
        
        /*Returns the convex hull of the arguments*/
        friend inline f_interval operator |(const f_interval &, const f_interval &);
        
        /*Returns the intersection of the arguments*/
        friend inline f_interval operator &(const f_interval &, const f_interval &);
        
        
        //Standard real+interval algebric addition. (real+f_interval)
        friend f_interval operator +(const real &, const f_interval &);
        
        //Standard real+interval algebric addition. (f_interval+real)
        friend f_interval operator +(const f_interval &, const real &);
        
        //Standard real-interval algebric subtraction. (real-f_interval)
        friend f_interval operator -(const real &, const f_interval &);
        
        //Standard real-interval algebric subtraction. (f_interval-real)
        friend f_interval operator -(const f_interval &, const real &);
        
        //Standard real*interval algebric multiplication (real*f_interval)
        friend f_interval operator *(const real &, const f_interval &);

        //Standard real*interval algebric multiplication (f_interval*real)
        friend f_interval operator *(const f_interval &, const real &);
        
        //Returns the convex hull of the arguments
        friend inline f_interval operator |(const real &, const f_interval &);
        
        //Returns the convex hull of the arguments
        friend inline f_interval operator |(const f_interval &, const real &);
        
        //Returns the convex hull of the arguments
        friend inline f_interval operator |(const real &, const real &);
        
        //Returns the intersection of the arguments
        friend inline f_interval operator &(const real &, const f_interval &);
        
        //Returns the intersection of the arguments
        friend inline f_interval operator &(const f_interval &, const real &);
        
        friend inline f_interval operator +=(f_interval &, const f_interval &);
        friend inline f_interval operator -=(f_interval &, const f_interval &);
        friend inline f_interval operator *=(f_interval &, const f_interval &);
        
        //--------END of Mathematical Functions---------//
        
        //--------------Comparsion Functions----------------//
        
        //Standard equality operation (f_interval==f_interval)
        friend inline bool operator ==(const f_interval &, const f_interval &); 
        
        //Standard negated equality operation (f_interval!=f_interval)
        friend inline bool operator !=(const f_interval &, const f_interval &);
        
        //Standard less-or-equal-than operation (f_interval<=f_interval)
        friend inline bool operator <=(const f_interval &, const f_interval &);

        //Standard greater-or-equal-than operation (f_interval>=f_interval)
        friend inline bool operator >=(const f_interval &, const f_interval &);
    
        //Standard greater-than operation (f_interval>f_interval)
        friend inline bool operator >(const f_interval &, const f_interval &);
        
        //Standard less-than operation (f_interval<f_interval)
        friend inline bool operator <(const f_interval &, const f_interval &);
        
        //-----------------END of Comparsion Functions-----------------//
        
};

#include "f_interval.inl"
